package com.sist.ocs.component;

import com.sist.ocs.model.User;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
public class MySender {

    @Autowired
    private RabbitTemplate rabbitTemplate;

    public void sendToDirect() {

        User user = new User();
        user.setPassword("123123");
        user.setUsername("xxx");

        System.out.println(user.toString());

        rabbitTemplate.convertAndSend("myDirectQue", user);
    }

    public void sendToTopic() {
        User user = new User();
        user.setPassword("111111");
        user.setUsername("admin");

        rabbitTemplate.convertAndSend("mytopicExchange","topic.myapp", user);
    }

    public void sendToFanout() {
        User user = new User();
        user.setPassword("222222");
        user.setUsername("root");

        rabbitTemplate.convertAndSend("myfanoutExchange","", user);
    }
}
